package socket

import (
	"github.com/gin-gonic/gin"
	"gopkg.in/ffmt.v1"
	"log"
	"zsgGin/interfaces"
)

func SocketRoute(route *gin.RouterGroup)  {
	route.GET("/websocket", func(context *gin.Context) {
		client,err:= Upgrade.Upgrade(context.Writer,context.Request,nil) //升级
		if err!=nil{
			log.Fatal(err.Error())
			return
		}
		//将此次连接放入到map中,并开启针对此次连接的 Ping,WriteLoop,ReadLoop,HandlerLoop 四个协程.(重点理解)
		ClientMap.Store(client)
	})
}




func ObjectTest(data any)  {
	animal:=data.(interfaces.Animal)
	animalCat:=animal.Name()
	ffmt.Puts(animalCat)
	ffmt.Puts(animal)
}